Imports System.Data

Partial Class Management_Info_MngtInfo
    Inherits WebPageCommon

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    'Dim sec As New Secure
    'sec.ParentPage = Me
    'sec.SetPageAccess(Session("UserName"))
    'sec = Nothing

    Dim pFunc As New PolyFunc.Secure

    If Not Page.IsPostBack Then
            'DataMining_btn_Click(sender, e)
      Commision_btn.Attributes.Add("onclick", "popUp('Generate.aspx?Q=" & pFunc.EncodeBase64("Commision") & "');")
      Issue_btn.Attributes.Add("onclick", "popUp('Generate.aspx?Q=" & pFunc.EncodeBase64("Issue") & "');")
      PolicySubmit_btn.Attributes.Add("onclick", "popUp('Generate.aspx?Q=" & pFunc.EncodeBase64("PolicySubmit") & "');")
    End If

    pFunc = Nothing

    Call setReportAccess()
  End Sub

    Private Sub setReportAccess()
        Dim dao As New DAOMain.CommonDAO

        With dao
            .AddParameter(Session("UserName"))

            Dim dt As DataTable = .ExecQryProc("sp_get_form_report_access")

            If dt.Rows.Count > 0 Then
                Dim i As Integer

                For i = 0 To dt.Rows.Count - 1
                    Dim lbtn As LinkButton = tblReport.FindControl(dt.Rows(i)("report_btn_id"))
                    Dim img As Image = tblReport.FindControl(dt.Rows(i)("report_img_id"))
                    If Not IsNothing(lbtn) Then lbtn.Visible = True
                    If Not IsNothing(img) Then img.Visible = True

                    lbtn = Nothing
                    img = Nothing
                Next
            End If
        End With

        dao = Nothing
    End Sub

    Protected Sub Aging_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Aging_btn.Click
        'ResetButtons()
        'A1.ImageUrl = "~/images/redT.PNG"
        'Aging_btn.ForeColor = Drawing.Color.Black

        'Filter_cmb.Items.Clear()
        'Dim zClass As New LookUp.General_Lookup
        'zClass.Loader(Filter_cmb, "AGENTS", "advisor_name", "user_name")
        'Filter_cmb.Items.Insert(0, "")
        'LabelChooser.Text = "Choose Consultant:"
        'A1Panel.Visible = True
        'Print_btn.Enabled = False

        ResetButtons()
        A1.ImageUrl = "~/images/redT.PNG"
        Aging_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If


        Session("sqlReport") = "Select * From vw_rpt_aging_unpaid_premium " & strFilter & " Order by Name, contribution_due_dt"
        Session("sqlUseTable") = "aging_unpaid_premium"
        Session("sqlUseReport") = "aging_unpaid_premium"
        Print_btn.Enabled = True

    End Sub

    Public Sub ResetButtons()
        A1.ImageUrl = "~/images/grayT.PNG"
        Aging_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A2.ImageUrl = "~/images/grayT.PNG"
        Birthday_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A3.ImageUrl = "~/images/grayT.PNG"
        Client1_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A4.ImageUrl = "~/images/grayT.PNG"
        Client2_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A5.ImageUrl = "~/images/grayT.PNG"
        Client3_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A6.ImageUrl = "~/images/grayT.PNG"
        Client4_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A7.ImageUrl = "~/images/grayT.PNG"
        Master1_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A8.ImageUrl = "~/images/grayT.PNG"
        Master2_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A9.ImageUrl = "~/images/grayT.PNG"
        Master3_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A10.ImageUrl = "~/images/grayT.PNG"
        Monthly1_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A11.ImageUrl = "~/images/grayT.PNG"
        Monthly2_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A12.ImageUrl = "~/images/grayT.PNG"
        Monthly3_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A13.ImageUrl = "~/images/grayT.PNG"
        Policy_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)
        A14.ImageUrl = "~/images/grayT.PNG"
        DataMining_btn.ForeColor = Drawing.Color.FromArgb(100, 153, 153, 153)

        A2Panel.Visible = False : A1Panel.Visible = False
        A3Panel.Visible = False : A4Panel.Visible = False
        A5Panel.Visible = False
        LabelChooser.Text = ""
    End Sub

    Protected Sub Filter_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Filter_cmb.SelectedIndexChanged
        If Filter_cmb.SelectedValue = "" Then Exit Sub

        If Aging_btn.ForeColor = Drawing.Color.Black Or Monthly3_btn.ForeColor = Drawing.Color.Black Then

            Session("sqlReport") = "Select * From vw_rpt_aging_unpaid_premium Order by Name, contribution_due_dt"
            Session("sqlUseTable") = "aging_unpaid_premium"
            Session("sqlUseReport") = "aging_unpaid_premium"
            Print_btn.Enabled = True

        End If

    End Sub

    Protected Sub Birthday_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Birthday_btn.Click
        ResetButtons()
        A2.ImageUrl = "~/images/redT.PNG"
        Birthday_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_birthday_list " & strFilter & " Order by month(Birthday), day(Birthday)"
        Session("sqlUseTable") = "birthday_list"
        Session("sqlUseReport") = "birthday_list"

    End Sub

    Protected Sub Client1_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Client1_btn.Click
        ResetButtons()
        A3.ImageUrl = "~/images/redT.PNG"
        Client1_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_client_profile " & strFilter & " Order by client_name"
        Session("sqlUseTable") = "vw_rpt_client_profile"
        Session("sqlUseReport") = "client_profile_city_provider"

    End Sub

    Protected Sub Client2_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Client2_btn.Click
        ResetButtons()
        A4.ImageUrl = "~/images/redT.PNG"
        Client2_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_client_profile " & strFilter & " Order by client_name"
        Session("sqlUseTable") = "vw_rpt_client_profile"
        Session("sqlUseReport") = "Client_Profile_City_ProductProvider_SumInsured"

    End Sub

    Protected Sub Client3_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Client3_btn.Click
        ResetButtons()
        A5.ImageUrl = "~/images/redT.PNG"
        Client3_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_client_profile " & strFilter & " Order by client_name"
        Session("sqlUseTable") = "vw_rpt_client_profile"
        Session("sqlUseReport") = "client_profile_city_provider_age"

    End Sub

    Protected Sub Client4_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Client4_btn.Click
        ResetButtons()
        A6.ImageUrl = "~/images/redT.PNG"
        Client4_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_client_profile " & strFilter & " Order by client_name"
        Session("sqlUseTable") = "vw_rpt_client_profile"
        Session("sqlUseReport") = "Client_Provider_Premium"

    End Sub

    Protected Sub Master1_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Master1_btn.Click
        ResetButtons()
        A7.ImageUrl = "~/images/redT.PNG"
        Master1_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_masterlist " & strFilter & " Order by client_name"
        Session("sqlUseTable") = "vw_rpt_masterlist"
        Session("sqlUseReport") = "Mastrerlist_Consultant"
    End Sub

    Protected Sub Master2_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Master2_btn.Click
        ResetButtons()
        A8.ImageUrl = "~/images/redT.PNG"
        Master2_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_masterlist " & strFilter & " Order by client_name"
        Session("sqlUseTable") = "vw_rpt_masterlist"
        Session("sqlUseReport") = "Mastrerlist_Status"

    End Sub

    Protected Sub Master3_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Master3_btn.Click
        ResetButtons()
        A9.ImageUrl = "~/images/redT.PNG"
        Master3_btn.ForeColor = Drawing.Color.Black

        A2Panel.Visible = True

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " Where Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Session("sqlReport") = "Select * From vw_rpt_masterlist " & strFilter & " Order by client_name"
        Session("sqlUseTable") = "vw_rpt_masterlist"
        Session("sqlUseReport") = "Mastrerlist_Insured_Age"

    End Sub

    Protected Sub Monthly3_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Monthly3_btn.Click
        ViewState("monthMode") = "Expire"
        ResetButtons()
        A12.ImageUrl = "~/images/redT.PNG"
        Monthly3_btn.ForeColor = Drawing.Color.Black

        A3Panel.Visible = True
        Dim startYear As Short = Year(Now) - 5

        Year_cmb.Items.Clear()

        Dim i As Integer
        For i = startYear To startYear + 10
            Year_cmb.Items.Add(i)
        Next i

        Month_cmb.SelectedValue = Month(Now)
        Year_cmb.SelectedValue = Year(Now)
        Call ChangeDate()
    End Sub

    Protected Sub Monthly1_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Monthly1_btn.Click
        ViewState("monthMode") = "Birthday"
        ResetButtons()
        A10.ImageUrl = "~/images/redT.PNG"
        Monthly1_btn.ForeColor = Drawing.Color.Black

        A3Panel.Visible = True
        Dim startYear As Short = Year(Now) - 5

        Year_cmb.Items.Clear()

        Dim i As Integer
        For i = startYear To startYear + 10
            Year_cmb.Items.Add(i)
        Next i

        Month_cmb.SelectedValue = Month(Now)
        Year_cmb.SelectedValue = Year(Now)
        Call ChangeDate()


    End Sub

    Protected Sub Monthly2_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Monthly2_btn.Click
        ViewState("monthMode") = "BirthdayEnvelope"
        ResetButtons()
        A11.ImageUrl = "~/images/redT.PNG"
        Monthly2_btn.ForeColor = Drawing.Color.Black

        A3Panel.Visible = True
        Dim startYear As Short = Year(Now) - 5

        Year_cmb.Items.Clear()

        Dim i As Integer
        For i = startYear To startYear + 10
            Year_cmb.Items.Add(i)
        Next i

        Month_cmb.SelectedValue = Month(Now)
        Year_cmb.SelectedValue = Year(Now)
        Call ChangeDate()


    End Sub

    Protected Sub Date_Change(ByVal sender As Object, ByVal e As System.EventArgs) Handles Month_cmb.SelectedIndexChanged, Year_cmb.SelectedIndexChanged
        Call ChangeDate()
    End Sub

    Private Sub ChangeDate()
        Dim strField As String = ""

        Dim strFilter As String = ""

        If Not IsNothing(Session("advisor")) Then
            strFilter = " And Advisor_Cd = '" & Session("UserName") & "'"
        End If

        Select Case ViewState("monthMode")
            Case "Birthday"
                Session("sqlReport") = "Select * From vw_rpt_mailmerge" & _
                                   " Where convert(datetime, convert(varchar(2), month(birthday)) + '/' + convert(varchar(2), day(birthday)) + '/' + '" & Year_cmb.SelectedValue & "')" & _
                                   " between '" & GetMonthStart(Month_cmb.SelectedValue, Year_cmb.SelectedValue) & "' And '" & GetMonthEnd(Month_cmb.SelectedValue, Year_cmb.SelectedValue) & "'" & _
                                   strFilter & _
                                   " Order by client_name"

                Session("sqlUseTable") = "vw_rpt_mailmerge"
                Session("sqlUseReport") = "Mailmerge_Birthday_Label"

            Case "BirthdayEnvelope"
                Session("sqlReport") = "Select * From vw_rpt_mailmerge" & _
                                   " Where convert(datetime, convert(varchar(2), month(birthday)) + '/' + convert(varchar(2), day(birthday)) + '/' + '" & Year_cmb.SelectedValue & "')" & _
                                   " between '" & GetMonthStart(Month_cmb.SelectedValue, Year_cmb.SelectedValue) & "' And '" & GetMonthEnd(Month_cmb.SelectedValue, Year_cmb.SelectedValue) & "'" & _
                                   strFilter & _
                                   " Order by client_name"

                Session("sqlUseTable") = "vw_rpt_mailmerge"
                Session("sqlUseReport") = "Mailmerge_Birthday_Envelope"

            Case "Expire"
                Session("sqlReport") = "Select * From vw_rpt_mailmerge" & _
                                   " Where Completion_dt " & _
                                   " between '" & GetMonthStart(Month_cmb.SelectedValue, Year_cmb.SelectedValue) & "' And '" & GetMonthEnd(Month_cmb.SelectedValue, Year_cmb.SelectedValue) & "'" & _
                                   strFilter & _
                                   " Order by client_name"

                Session("sqlUseTable") = "vw_rpt_mailmerge"
                Session("sqlUseReport") = "Mailmerge_Renewal"
        End Select
    End Sub

    Private Function GetMonthStart(ByVal m As Integer, ByVal y As Integer) As String
        Dim strReturn As String = ""

        strReturn = CStr(m) & "/1/" & CStr(y)

        Return strReturn
    End Function

    Private Function GetMonthEnd(ByVal m As Integer, ByVal y As Integer) As String
        Dim strReturn As String = ""
        Dim tDate As Date

        strReturn = CStr(m) & "/1/" & CStr(y)

        tDate = CDate(strReturn)
        tDate = DateAdd(DateInterval.Month, 1, tDate)
        tDate = DateAdd(DateInterval.Day, -1, tDate)

        strReturn = CStr(Month(tDate)) & "/" & CStr(Day(tDate)) & "/" & CStr(Year(tDate))

        Return strReturn
    End Function

    Protected Sub Policy_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Policy_btn.Click
        'ResetButtons()
        'A1.ImageUrl = "~/images/redT.PNG"
        'Aging_btn.ForeColor = Drawing.Color.Black

        'Filter_cmb.Items.Clear()
        'Dim zClass As New LookUp.General_Lookup
        'zClass.Loader(Filter_cmb, "AGENTS", "advisor_name", "user_name")
        'Filter_cmb.Items.Insert(0, "")
        'LabelChooser.Text = "Choose Consultant:"
        'A1Panel.Visible = True
        'Print_btn.Enabled = False

        ResetButtons()
        A13.ImageUrl = "~/images/redT.PNG"
        Policy_btn.ForeColor = Drawing.Color.Black

        policy_cmb.Items.Clear()
        Dim zClass As New LookUp.General_Lookup
        zClass.Loader(policy_cmb, "POLICY", "policy_no", "policy_no")
        policy_cmb.Items.Insert(0, "")

        A4Panel.Visible = True

        Session("sqlUseTable") = "mpz_Main"
        Session("sqlUseReport") = "PolicyAllDetails"

    End Sub

    Protected Sub policy_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles policy_cmb.SelectedIndexChanged
        If policy_cmb.SelectedValue = "" Then Exit Sub
        Session("sqlReport") = policy_cmb.SelectedValue
        Button2.Enabled = True
    End Sub

    Protected Sub DataMining_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataMining_btn.Click
        ResetButtons()
        A14.ImageUrl = "~/images/redT.PNG"
        DataMining_btn.ForeColor = Drawing.Color.Black

        A5Panel.Visible = True
        tblMenu.Visible = False

        'Session("sqlReport") = "Select * From vw_rpt_birthday_list Order by month(Birthday), day(Birthday)"
        'Session("sqlUseTable") = "data_mine"
        Session("sqlUseReport") = "data_mine"

        Dim zClass As New LookUp.General_Lookup

    AgentCode_cmb.Items.Clear()
    zClass.Loader(AgentCode_cmb, "vw_policy_adv_dtl", "advisor_cd", "advisor_cd")
    AgentCode_cmb.Items.Insert(0, "")

    Currecy_of_Policy_cmb.Items.Clear()
    zClass.Loader(Currecy_of_Policy_cmb, "Currency_of_Policy", "Lookup_desc", "Lookup_desc")
    Currecy_of_Policy_cmb.Items.Insert(0, "")

    Frequency_of_Payment_cmb.Items.Clear()
    zClass.Loader(Frequency_of_Payment_cmb, "Frequency_of_Payment", "frequency_desc", "frequency_desc")
    Frequency_of_Payment_cmb.Items.Insert(0, "")

        Policy_Status_cmb.Items.Clear()
        zClass.Loader(Policy_Status_cmb, "POLICY_STATUS", "Lookup_desc", "Lookup_desc")
        Policy_Status_cmb.Items.Insert(0, "")

    'Process_Status_cmb.Items.Clear()
    'zClass.Loader(Process_Status_cmb, "PROCESS_STATUS", "Lookup_desc", "Lookup_desc")
    If Process_Status_cmb.Items.Count = 2 Then Process_Status_cmb.Items.Insert(0, "")

    Payment_Status_cmb.Items.Clear()
    zClass.Loader(Payment_Status_cmb, "PAYMENT_STATUS", "Lookup_desc", "Lookup_desc")
    Payment_Status_cmb.Items.Insert(0, "")

    Owner_Sex_cmb.Items.Clear()
    zClass.Loader(Owner_Sex_cmb, "GENDER", "Lookup_desc", "Lookup_desc")
    Owner_Sex_cmb.Items.Insert(0, "")

    Owner_Civil_Status_cmb.Items.Clear()
    zClass.Loader(Owner_Civil_Status_cmb, "MARITAL_STATUS", "Lookup_desc", "Lookup_desc")
    Owner_Civil_Status_cmb.Items.Insert(0, "")

    Insured_Sex_cmb.Items.Clear()
    zClass.Loader(Insured_Sex_cmb, "GENDER", "Lookup_desc", "Lookup_desc")
    Insured_Sex_cmb.Items.Insert(0, "")

    Insured_Civil_Status_cmb.Items.Clear()
    zClass.Loader(Insured_Civil_Status_cmb, "MARITAL_STATUS", "Lookup_desc", "Lookup_desc")
    Insured_Civil_Status_cmb.Items.Insert(0, "")


    On Error Resume Next
    Session.Remove("DM_AgentCode") : Session.Remove("DM_SumInsured") : Session.Remove("DM_Currecy_of_Policy")
    Session.Remove("DM_Frequency_of_Payment") : Session.Remove("DM_Policy_Issue_Date")
    Session.Remove("DM_Maturity_Term") : Session.Remove("DM_First_Premium_Due_Date")

    Session.Remove("DM_Final_Premium_Due_Date") : Session.Remove("DM_Payment_Status")

    Session.Remove("DM_Policy_Status") : Session.Remove("DM_Process_Status")
    Session.Remove("DM_Owner_Name") : Session.Remove("DM_Owner_Birth_Date")
    Session.Remove("DM_Owner_Occupation") : Session.Remove("DM_Owner_Employment_Income")
    Session.Remove("DM_Owner_Net_Worth") : Session.Remove("DM_Owner_Sex")
    Session.Remove("DM_Owner_Civil_Status")
    Session.Remove("DM_Insured_Name") : Session.Remove("DM_Insured_Birth_Date")
    Session.Remove("DM_Insured_Occupation") : Session.Remove("DM_Insured_Sex")
    Session.Remove("DM_Insured_Civil_Status")
  End Sub

    Protected Sub lbtnBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnBack.Click
        A5Panel.Visible = False
        tblMenu.Visible = True

        On Error Resume Next
        Session.Remove("DM_AgentCode") : Session.Remove("DM_SumInsured") : Session.Remove("DM_Currecy_of_Policy")
        Session.Remove("DM_Frequency_of_Payment") : Session.Remove("DM_Policy_Issue_Date")
        Session.Remove("DM_Maturity_Term") : Session.Remove("DM_First_Premium_Due_Date")

        Session.Remove("DM_Final_Premium_Due_Date") : Session.Remove("DM_Payment_Status")

        Session.Remove("DM_Policy_Status") : Session.Remove("DM_Process_Status")
        Session.Remove("DM_Owner_Name") : Session.Remove("DM_Owner_Birth_Date")
        Session.Remove("DM_Owner_Occupation") : Session.Remove("DM_Owner_Employment_Income")
        Session.Remove("DM_Owner_Net_Worth") : Session.Remove("DM_Owner_Sex")
        Session.Remove("DM_Owner_Civil_Status")
        Session.Remove("DM_Insured_Name") : Session.Remove("DM_Insured_Birth_Date")
        Session.Remove("DM_Insured_Occupation") : Session.Remove("DM_Insured_Sex")
        Session.Remove("DM_Insured_Civil_Status")
    End Sub

#Region "Data Mining"

  Protected Sub AgentCode_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AgentCode_cmb.TextChanged
    If Trim(AgentCode_cmb.SelectedItem.Text) <> "" Then
      Session("DM_AgentCode") = Trim(AgentCode_cmb.SelectedItem.Text)
    Else
      On Error Resume Next
      Session.Remove("DM_AgentCode")
    End If
  End Sub

    Protected Sub SumInsured_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SumInsured_txt.TextChanged
        If Trim(SumInsured_txt.Text) <> "" Then
            Session("DM_SumInsured") = Trim(SumInsured_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_SumInsured")
        End If
    End Sub

  Protected Sub Currecy_of_Policy_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Currecy_of_Policy_cmb.TextChanged
    If Trim(Currecy_of_Policy_cmb.SelectedItem.Text) <> "" Then
      Session("DM_Currecy_of_Policy") = Trim(Currecy_of_Policy_cmb.SelectedItem.Text)
    Else
      On Error Resume Next
      Session.Remove("DM_Currecy_of_Policy")
    End If
  End Sub

  Protected Sub Frequency_of_Payment_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Frequency_of_Payment_cmb.TextChanged
    If Trim(Frequency_of_Payment_cmb.SelectedItem.Text) <> "" Then
      Session("DM_Frequency_of_Payment") = Trim(Frequency_of_Payment_cmb.SelectedItem.Text)
    Else
      On Error Resume Next
      Session.Remove("DM_Frequency_of_Payment")
    End If
  End Sub

    Protected Sub Policy_Issue_Date_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Policy_Issue_Date_txt.TextChanged
        If Trim(Policy_Issue_Date_txt.Text) <> "" Then
            Session("DM_Policy_Issue_Date") = Trim(Policy_Issue_Date_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Policy_Issue_Date")
        End If
    End Sub

    Protected Sub Maturity_Term_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Maturity_Term_txt.TextChanged
        If Trim(Maturity_Term_txt.Text) <> "" Then
            Session("DM_Maturity_Term") = Trim(Maturity_Term_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Maturity_Term")
        End If
    End Sub

    Protected Sub First_Premium_Due_Date_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles First_Premium_Due_Date_txt.TextChanged
        If Trim(First_Premium_Due_Date_txt.Text) <> "" Then
            Session("DM_First_Premium_Due_Date") = Trim(First_Premium_Due_Date_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_First_Premium_Due_Date")
        End If
    End Sub

    Protected Sub Final_Premium_Due_Date_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Final_Premium_Due_Date_txt.TextChanged
        If Trim(Final_Premium_Due_Date_txt.Text) <> "" Then
            Session("DM_Final_Premium_Due_Date") = Trim(Final_Premium_Due_Date_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Final_Premium_Due_Date")
        End If
    End Sub

    Protected Sub Policy_Status_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Policy_Status_cmb.SelectedIndexChanged
        If Trim(Policy_Status_cmb.SelectedItem.Text) <> "" Then
            Session("DM_Policy_Status") = Trim(Policy_Status_cmb.SelectedItem.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Policy_Status")
        End If
    End Sub

    Protected Sub Process_Status_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Process_Status_cmb.SelectedIndexChanged
        If Trim(Process_Status_cmb.SelectedItem.Text) <> "" Then
            Session("DM_Process_Status") = Trim(Process_Status_cmb.SelectedItem.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Process_Status")
        End If
    End Sub

    Protected Sub Payment_Status_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Payment_Status_cmb.SelectedIndexChanged
        If Trim(Payment_Status_cmb.SelectedItem.Text) <> "" Then
            Session("DM_Payment_Status") = Trim(Payment_Status_cmb.SelectedItem.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Payment_Status")
        End If
    End Sub

    Protected Sub Owner_Name_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Owner_Name_txt.TextChanged
        If Trim(Owner_Name_txt.Text) <> "" Then
            Session("DM_Owner_Name") = Trim(Owner_Name_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Owner_Name")
        End If
    End Sub

    Protected Sub Owner_Birth_Date_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Owner_Birth_Date_txt.TextChanged
        If Trim(Owner_Birth_Date_txt.Text) <> "" Then
            Session("DM_Owner_Birth_Date") = Trim(Owner_Birth_Date_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Owner_Birth_Date")
        End If
    End Sub

    Protected Sub Insured_Name_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Insured_Name_txt.TextChanged
        If Trim(Insured_Name_txt.Text) <> "" Then
            Session("DM_Insured_Name") = Trim(Insured_Name_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Insured_Name")
        End If
    End Sub

    Protected Sub Insured_Birth_Date_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Insured_Birth_Date_txt.TextChanged
        If Trim(Insured_Birth_Date_txt.Text) <> "" Then
            Session("DM_Insured_Birth_Date") = Trim(Insured_Birth_Date_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Insured_Birth_Date")
        End If
    End Sub

    Protected Sub Owner_Occupation_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Owner_Occupation_txt.TextChanged
        If Trim(Owner_Occupation_txt.Text) <> "" Then
            Session("DM_Owner_Occupation") = Trim(Owner_Occupation_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Owner_Occupation")
        End If
    End Sub

    Protected Sub Owner_Employment_Income_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Owner_Employment_Income_txt.TextChanged
        If Trim(Owner_Employment_Income_txt.Text) <> "" Then
            Session("DM_Owner_Employment_Income") = Trim(Owner_Employment_Income_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Owner_Employment_Income")
        End If
    End Sub

    Protected Sub Owner_Net_Worth_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Owner_Net_Worth_txt.TextChanged
        If Trim(Owner_Net_Worth_txt.Text) <> "" Then
            Session("DM_Owner_Net_Worth") = Trim(Owner_Net_Worth_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Owner_Net_Worth")
        End If
    End Sub

    Protected Sub Insured_Occupation_txt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Insured_Occupation_txt.TextChanged
        If Trim(Insured_Occupation_txt.Text) <> "" Then
            Session("DM_Insured_Occupation") = Trim(Insured_Occupation_txt.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Insured_Occupation")
        End If
    End Sub

    Protected Sub Owner_Sex_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Owner_Sex_cmb.SelectedIndexChanged
        If Trim(Owner_Sex_cmb.SelectedItem.Text) <> "" Then
            Session("DM_Owner_Sex") = Trim(Owner_Sex_cmb.SelectedItem.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Owner_Sex")
        End If
    End Sub

    Protected Sub Owner_Civil_Status_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Owner_Civil_Status_cmb.SelectedIndexChanged
        If Trim(Owner_Civil_Status_cmb.SelectedItem.Text) <> "" Then
            Session("DM_Owner_Civil_Status") = Trim(Owner_Civil_Status_cmb.SelectedItem.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Owner_Civil_Status")
        End If
    End Sub

    Protected Sub Insured_Sex_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Insured_Sex_cmb.SelectedIndexChanged
        If Trim(Insured_Sex_cmb.SelectedItem.Text) <> "" Then
            Session("DM_Insured_Sex") = Trim(Insured_Sex_cmb.SelectedItem.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Insured_Sex")
        End If
    End Sub

    Protected Sub Insured_Civil_Status_cmb_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Insured_Civil_Status_cmb.SelectedIndexChanged
        If Trim(Insured_Civil_Status_cmb.SelectedItem.Text) <> "" Then
            Session("DM_Insured_Civil_Status") = Trim(Insured_Civil_Status_cmb.SelectedItem.Text)
        Else
            On Error Resume Next
            Session.Remove("DM_Insured_Civil_Status")
        End If
    End Sub

#End Region

    
End Class

'--vwAging--
'
'SELECT     dbo.policy_client_dtl.policy_client_salutation, 
'                      dbo.policy_client_dtl.policy_client_last_name + ', ' + dbo.policy_client_dtl.policy_client_first_name + ' ' + dbo.policy_client_dtl.policy_client_middle_name
'                       AS Name, dbo.policy_client_dtl.policy_client_alias, dbo.policy_trans.policy_seq_cd AS PolicyNo, 
'                      dbo.policy_premium_dtl.contribution_amt AS PremiumDue, dbo.policy_trans.contribution_due_dt
'FROM         dbo.policy_client_dtl INNER JOIN
'                      dbo.policy_trans ON dbo.policy_client_dtl.policy_seq_cd = dbo.policy_trans.policy_seq_cd INNER JOIN
'                      dbo.policy_premium_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_premium_dtl.policy_seq_cd

'--vwBirthday--
'
'SELECT     policy_client_salutation, policy_client_last_name + ', ' + policy_client_first_name + ' ' + policy_client_middle_name AS Name, policy_client_alias, 
' birthday
' FROM dbo.policy_client_dtl

'--vwClient1--
'
'SELECT     dbo.policy_client_dtl.policy_client_last_name + ', ' + dbo.policy_client_dtl.policy_client_first_name + ' ' + dbo.policy_client_dtl.policy_client_middle_name
'                       AS Name, dbo.policy_client_dtl.policy_client_salutation, dbo.policy_client_dtl.policy_client_alias, dbo.policy_client_dtl.city_cd AS City, 
'                      dbo.provider_mstr.provider_desc AS Provider, dbo.prdt_mstr.prdt_desc AS Product, dbo.policy_trans.insured_amt AS SumInsured, 
'                      dbo.policy_trans.commence_age AS Age, dbo.policy_trans.contribution_amt AS Premium
'FROM         dbo.policy_client_dtl INNER JOIN
'                      dbo.policy_trans ON dbo.policy_client_dtl.policy_seq_cd = dbo.policy_trans.policy_seq_cd INNER JOIN
'                      dbo.prdt_mstr ON dbo.policy_trans.prdt_cd = dbo.prdt_mstr.prdt_cd INNER JOIN
'                      dbo.provider_mstr ON dbo.policy_trans.provider_cd = dbo.provider_mstr.provider_cd AND dbo.prdt_mstr.provider_cd = dbo.provider_mstr.provider_cd

'--vwMaster1--
'
'SELECT     dbo.policy_client_dtl.policy_client_last_name + ', ' + dbo.policy_client_dtl.policy_client_first_name + ' ' + dbo.policy_client_dtl.policy_client_middle_name
'                       AS OwnerName, 
'                      dbo.policy_insured_dtl.policy_insured_last_name + ', ' + dbo.policy_insured_dtl.policy_insured_first_name + ' ' + dbo.policy_insured_dtl.policy_insured_middle_name
'                       AS InsuredName, dbo.policy_trans.policy_seq_cd, dbo.policy_client_dtl.birthday, dbo.provider_mstr.provider_desc, dbo.prdt_mstr.prdt_desc, 
'                      dbo.policy_trans.insured_amt, dbo.policy_trans.policy_issue_dt, dbo.policy_trans.policy_st, dbo.policy_trans.vanish_yrs, 
'                      dbo.lookup_mstr.Lookup_desc AS Curr, lookup_mstr_1.Lookup_desc AS Freq, SUM(dbo.policy_premium_dtl.contribution_amt) AS Contri, 
'                      dbo.user_mstr.user_last_name + ', ' + dbo.user_mstr.user_first_name + ' ' + dbo.user_mstr.user_middle_name AS AgentName
'FROM         dbo.policy_trans INNER JOIN
'                      dbo.policy_client_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_client_dtl.policy_seq_cd INNER JOIN
'                      dbo.policy_insured_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_insured_dtl.policy_seq_cd INNER JOIN
'                      dbo.provider_mstr ON dbo.policy_trans.provider_cd = dbo.provider_mstr.provider_cd INNER JOIN
'                      dbo.prdt_mstr ON dbo.policy_trans.prdt_cd = dbo.prdt_mstr.prdt_cd AND dbo.provider_mstr.provider_cd = dbo.prdt_mstr.provider_cd INNER JOIN
'                      dbo.lookup_mstr ON dbo.policy_trans.payment_curr = dbo.lookup_mstr.Lookup_seq INNER JOIN
'                      dbo.lookup_mstr AS lookup_mstr_1 ON dbo.policy_trans.frequency_cd = lookup_mstr_1.Lookup_seq INNER JOIN
'                      dbo.policy_premium_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_premium_dtl.policy_seq_cd INNER JOIN
'                      dbo.policy_adv_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_adv_dtl.policy_seq_cd INNER JOIN
'                      dbo.user_mstr ON dbo.policy_adv_dtl.advisor_cd = dbo.user_mstr.user_name
'WHERE     (dbo.lookup_mstr.Lookup_cd = N'CURRENCY') AND (lookup_mstr_1.Lookup_cd = N'PAYMENT_FREQUENCY') AND 
'                      (dbo.policy_premium_dtl.pay_tag = 1)
'GROUP BY dbo.policy_client_dtl.policy_client_last_name, dbo.policy_client_dtl.policy_client_first_name, dbo.policy_client_dtl.policy_client_middle_name, 
'                      dbo.policy_insured_dtl.policy_insured_last_name, dbo.policy_insured_dtl.policy_insured_first_name, 
'                      dbo.policy_insured_dtl.policy_insured_middle_name, dbo.policy_trans.policy_seq_cd, dbo.provider_mstr.provider_desc, dbo.prdt_mstr.prdt_desc, 
'                      dbo.policy_trans.insured_amt, dbo.policy_trans.policy_issue_dt, dbo.policy_trans.policy_st, dbo.policy_trans.vanish_yrs, 
'                      dbo.lookup_mstr.Lookup_desc, lookup_mstr_1.Lookup_desc, dbo.policy_client_dtl.birthday, dbo.user_mstr.user_last_name, 
'    dbo.user_mstr.user_first_name, dbo.user_mstr.user_middle_name

'--vwMaster3--
'
'SELECT     dbo.policy_client_dtl.policy_client_last_name + ', ' + dbo.policy_client_dtl.policy_client_first_name + ' ' + dbo.policy_client_dtl.policy_client_middle_name
'                       AS OwnerName, 
'                      dbo.policy_insured_dtl.policy_insured_last_name + ', ' + dbo.policy_insured_dtl.policy_insured_first_name + ' ' + dbo.policy_insured_dtl.policy_insured_middle_name
'                       AS InsuredName, dbo.policy_trans.policy_seq_cd, dbo.policy_client_dtl.birthday, dbo.provider_mstr.provider_desc, dbo.prdt_mstr.prdt_desc, 
'                      dbo.policy_trans.insured_amt, dbo.policy_trans.policy_issue_dt, dbo.policy_trans.policy_st, dbo.policy_trans.vanish_yrs, 
'                      dbo.lookup_mstr.Lookup_desc AS Curr, lookup_mstr_1.Lookup_desc AS Freq, SUM(dbo.policy_premium_dtl.contribution_amt) AS Contri, 
'                      dbo.user_mstr.user_last_name + ', ' + dbo.user_mstr.user_first_name + ' ' + dbo.user_mstr.user_middle_name AS AgentName, 
'                       dbo.policy_trans.commence_age
'FROM         dbo.policy_trans INNER JOIN
'                      dbo.policy_client_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_client_dtl.policy_seq_cd INNER JOIN
'                      dbo.policy_insured_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_insured_dtl.policy_seq_cd INNER JOIN
'                      dbo.provider_mstr ON dbo.policy_trans.provider_cd = dbo.provider_mstr.provider_cd INNER JOIN
'                      dbo.prdt_mstr ON dbo.policy_trans.prdt_cd = dbo.prdt_mstr.prdt_cd AND dbo.provider_mstr.provider_cd = dbo.prdt_mstr.provider_cd INNER JOIN
'                      dbo.lookup_mstr ON dbo.policy_trans.payment_curr = dbo.lookup_mstr.Lookup_seq INNER JOIN
'                      dbo.lookup_mstr AS lookup_mstr_1 ON dbo.policy_trans.frequency_cd = lookup_mstr_1.Lookup_seq INNER JOIN
'                      dbo.policy_premium_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_premium_dtl.policy_seq_cd INNER JOIN
'                      dbo.policy_adv_dtl ON dbo.policy_trans.policy_seq_cd = dbo.policy_adv_dtl.policy_seq_cd INNER JOIN
'                      dbo.user_mstr ON dbo.policy_adv_dtl.advisor_cd = dbo.user_mstr.user_name
'WHERE     (dbo.lookup_mstr.Lookup_cd = N'CURRENCY') AND (lookup_mstr_1.Lookup_cd = N'PAYMENT_FREQUENCY') AND 
'                      (dbo.policy_premium_dtl.pay_tag = 1)
'GROUP BY dbo.policy_client_dtl.policy_client_last_name, dbo.policy_client_dtl.policy_client_first_name, dbo.policy_client_dtl.policy_client_middle_name, 
'                  dbo.policy_insured_dtl.policy_insured_last_name, dbo.policy_insured_dtl.policy_insured_first_name, 
'                  dbo.policy_insured_dtl.policy_insured_middle_name, dbo.policy_trans.policy_seq_cd, dbo.provider_mstr.provider_desc, dbo.prdt_mstr.prdt_desc, 
'                  dbo.policy_trans.insured_amt, dbo.policy_trans.policy_issue_dt, dbo.policy_trans.policy_st, dbo.policy_trans.vanish_yrs, 
'                  dbo.lookup_mstr.Lookup_desc, lookup_mstr_1.Lookup_desc, dbo.policy_client_dtl.birthday, dbo.user_mstr.user_last_name, 
'dbo.user_mstr.user_first_name, dbo.user_mstr.user_middle_name, dbo.policy_trans.commence_age